<template>
  <el-dialog v-model="visible" title="证书申请" width="500px">
    <el-form-item label="企业名" prop="company">
    </el-form-item>
    <el-form-item label="特征码" prop="code">
    </el-form-item>        
    <el-form-item label="试用天数" prop="expire">
    </el-form-item>
    <el-button type="primary" @click="copyLicenseApply">复制</el-button>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, watch } from 'vue'
import useClipboard from "vue-clipboard3";
import { ElNotification } from 'element-plus';

const visible = ref(false)
const props = defineProps({modelValue: Boolean})
const emit = defineEmits(['update:modelValue'])

watch(() => props.modelValue, (val) => {
    visible.value = val
})

watch(visible, (val) => {
emit('update:modelValue', val)
})

const { toClipboard } = useClipboard()

const copyLicenseApply = async () => {
    try {
    await toClipboard('Any text you like')
    ElNotification({"message": "复制成功", "type": "success"})
    } catch (e) {
    ElNotification({"message": "复制失败", "type": "warning"})
    }
}
</script>

<style>
</style>
